<?php
	session_start();
	include('../functions/soap.php');
	include('head.php');

	//Kijk of er is ingelogd
	if(!isset($_SESSION['session']))
	{
		header('Location: ../');
	}
?>

<body>

    <div class="wrapper">

    	<div class="header"><img src="../img/logo.gif" /></div>
        <?php include('logininfo.php') ?>
        <div class="menu"><?php include('menu.php'); ?></div>
		<div class="sidebar">

			<?php include('../copyrightBox.php') ?>

		</div>

    	<div class="content">
        	<h3 class="header">Docent Overzicht</h3>
			<?php
				//Maak een getDocent object aan
				$docent = new GetDocent($wsdl);
				//Vraag om een lijstje van alle docenten
				$docentenArray = $docent->getDocenten();
				
				$rol = $_SESSION['Rol'];
				
				//Maak de table head aan
				
				$docentTable = '<table width="100%">';
				$docentTable.= '<tr width="100%">';
				$docentTable.= '<th width="5%">&nbsp;</th>';
				$docentTable.= '<th width="15%">Stamnummer</th>';
				$docentTable.= '<th width="10%">Naam</th>';
				$docentTable.= '<th width="20%">Email</th>';
				$docentTable.= '<th width="20%">Telefoonnr</th>';
				
				if($rol == 'Admin' || $rol == 'Administratie')
				{
					$docentTable.='<th width="20%">&nbsp;</th>';
				}
				
				$docentTable.= '<thwidth="10%">&nbsp;</th>';
				
				if($rol == 'Admin' || $rol == 'Administratie')
				{
					$docentTable.= '<th width="10%">&nbsp;</th>';
				}
				$docentTable.= "</tr></table>";
				
				$i = 0;
				$javascript = '';
				
				//Loop door de studentenArray heen en schrijf deze weg op het scherm
				foreach($docentenArray as $record)
				{
					$docentTable.= '<table width="100%"><tr width="100%" id="student'.$i.'">';
					$docentTable.= '<td width="5%">[<a href="#" id="v_toggle'.$i.'" name="v_toggle'.$i.'">+</a>]</td>';
										
					$docentTable.= '<td width="20%">'. $record->getStamnummer().'</td>';
					$docentTable.= '<td width="25%">'.$record->getFullName().'</td>';
					$docentTable.= '<td width="30%">'.$record->getEmail().'</td>';
					$docentTable.= '<td width="30%">'.$record->getTelefoonnr().'</td>';
					
					if($rol == 'Admin' || $rol == 'Administratie')
					{
						$docentTable.= '<td width="20%"><a href="docent_bewerken.php?id='.$record->getId().'">Bewerk</a></td>';
					}
					
					$docentTable.= "</tr></table>";
					$stageTable = '<div width="400" id="slide'.$i.'" class="slider">';
					
					if(sizeof($record->getStages()) > 0 || $record->getStages() != NULL)
					{
						$stageTable.= '<table width="100%">';
						$stageTable.= '<tr width="100%">';
						$stageTable.= '<th width="15%">Type</th>';
						$stageTable.= '<th width="10%">Van</th>';
						$stageTable.= '<th width="10%">Tot</th>';
						$stageTable.= '<th width="20%">Bedrijf</th>';
						$stageTable.= '<th width="15%">Status</th>';
						$stageTable.= '<th width="10%">&nbsp;</th>';
						$stageTable.= '</tr>';
						
						$stages = $record->getStages();
						foreach($stages as $stage)
						{
							$stageTable.= '<tr width="100%">';
							$stageTable.= '<td width="10%">'.$stage->getType().'</td>';
							$stageTable.= '<td width="10%">'.$stage->getVan().'</td>';
							$stageTable.= '<td width="10%">'.$stage->getTot().'</td>';
							
							$getContact = new GetContact($wsdl);
							$contact = $getContact->getContact($stage->getBedrijfsbegeleider());
							
							$getBedrijf = new getBedrijf($wsdl);
							$bedrijf = $getBedrijf->getBedrijf($contact->getBedrijf());
							
							$stageTable.= '<td width="15%">'.$bedrijf->getBedrijfsnaam().'</td>';
							$stageTable.= '<td width="15%">'.$stage->getStatus().'</td>';
							$stageTable.= '<td width="10%"><a href="stage_bekijken.php?id='.$stage->getId().'">Bekijk</a></td>';
							$stageTable.= '</tr>';
						}
						$stageTable.= '</table>';
					}
					
					$stageTable.= '</div>';
					
					$docentTable.= $stageTable;
					
					$javascript.= "\n var myVerticalSlide".$i." = new Fx.Slide('slide".$i."').hide();
$('v_toggle".$i."').addEvent('click', function()
{
	myVerticalSlide".$i.".toggle();
});\n
								   ";
					$i++;
				}
				
				$javascript = '<script type="text/javascript">
window.addEvent(\'domready\', function(){'. $javascript;
				$javascript = $javascript.'	});
</script>';
				$docentTable = $javascript . $docentTable;
				
				//Docent kunnen toevoegen
				if($rol == 'Admin' || $rol == 'Administratie')
				{
					$docentTable.= '<br />><a href="docent_toevoegen.php">Docent toevoegen</a>';
				}

				echo($docentTable);
			?>
        </div>
    </div>
</body>
</html>
